package com.woniuxy.propertyjava.controller;

import com.woniuxy.propertyjava.entity.PageBean;
import com.woniuxy.propertyjava.entity.Propertyconteanct;
import com.woniuxy.propertyjava.entity.ResponseResult;
import com.woniuxy.propertyjava.service.PropertyconteanctService;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;

/**
 * (Propertyconteanct)表控制层
 *
 * @author makejava
 * @since 2022-07-08 12:07:38
 */
@RestController
public class PropertyconteanctController {
    /**
     * 服务对象
     */
    @Resource
    private PropertyconteanctService propertyconteanctService;

    /**
     * 分页查询
     *
     *  propertyconteanct 筛选条件
     * pageRequest      分页对象
     * @return 查询结果
     */
    @PostMapping("/propertyconteanct/{pageIndex}/{pageSize}")
    public ResponseResult<PageBean<Propertyconteanct>> queryByPage(
            @PathVariable("pageIndex") int pageIndex,
            @PathVariable("pageSize") int pageSize,
            @RequestBody Propertyconteanct propertyconteanct) {
        PageBean<Propertyconteanct>pageBean= propertyconteanctService.queryByPage(propertyconteanct, pageIndex, pageSize);
        return new ResponseResult<>(200,"ok",pageBean);
    }
    /**
     * 通过主键查询单条数据
     *
     * @param pcid 主键
     * @return 单条数据
     */
    @GetMapping("/propertyconteanct{pcid}")
    public ResponseEntity<Propertyconteanct> queryById(@PathVariable("pcid") Integer pcid) {
        return ResponseEntity.ok(this.propertyconteanctService.queryById(pcid));
    }

    /**
     * 新增数据
     *
     * @ propertyconteanct 实体
     * @return 新增结果
     */
    @PostMapping("/propertyconteanct")
    public ResponseResult<Propertyconteanct> add(@RequestBody Propertyconteanct propertyconteanct) {
        propertyconteanctService.insert(propertyconteanct);
        return new ResponseResult<>(200, "ok", null);
    }


    /**
     * 编辑数据
     *
     * @param propertyconteanct 实体
     * @return 编辑结果
     */
    @PutMapping("/propertyconteanct")
    public ResponseResult<Propertyconteanct> edit(@RequestBody Propertyconteanct propertyconteanct) {
        propertyconteanctService.update(propertyconteanct);
        return new ResponseResult<>(200, "ok", propertyconteanct);
    }

    /**
     * 删除数据
     *
     * pcid 主键
     * @return 删除是否成功
     */
    @DeleteMapping("/propertyconteanct/{pcid}")
    public ResponseResult<Boolean> deleteById(@PathVariable("pcid") Integer pcid) {
        return new ResponseResult<>(200, "ok", propertyconteanctService.deleteById(pcid));
    }
}

